package com.dyrj.pig.controller;


import com.dyrj.pig.bean.TUser;
import com.dyrj.pig.service.TUserService;
import com.dyrj.vo.PageResultMsg;
import com.dyrj.vo.ResultMsg;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Controller
@RequestMapping("/pig/user")
public class TUserController {

    @Resource
    private TUserService tUserService;

    @GetMapping("/index")
    public String index(ModelMap map) {
        return "pig/index_user";
    }

    @GetMapping("/table")
    @ResponseBody
    public PageResultMsg table(TUser record) {
        if(record.getLx()==null){
            record.setLx(record.getQlx());
        }
        return tUserService.table(record);
    }

    @GetMapping("/{id}")
    @ResponseBody
    public TUser info(@PathVariable String id) {
        return tUserService.info(id);
    }


    @PutMapping("/")
    @ResponseBody
    public ResultMsg update(TUser record) {
        return tUserService.update(record);
    }

    @DeleteMapping("/{id}")
    @ResponseBody
    public ResultMsg delete(@PathVariable String id) {
        return tUserService.delete(id);
    }

    @PostMapping("/")
    @ResponseBody
    public ResultMsg add(TUser record) {
        return tUserService.add(record);
    }

    @PostMapping("/createsubno")
    @ResponseBody
    public ResultMsg createsubno(TUser record) {

        return tUserService.createsubno(record);
    }


}
